import handler from '.'

const state = (
  state = { ...handler.state },
  action: { type: string; val: number }
) => {
  let newState = JSON.parse(JSON.stringify(state))

  for (let key in handler.actionName) {
    if (handler.actionName[key] === action.type) {
      handler.actions[key](newState, action)
      break
    }
  }
  return newState
}

export default state
